function delbyID() {
	var row = $('#dg').datagrid('getSelected');
	if (row) {
		$.post(del_url, {
			id : row["id"]
		}).done(function(json) {
			if (json.result) {
				$('#dg').datagrid('reload');
			} else {
				alert(json.msg);
			}
		}, "json");
	} else {
		alert("请先选中要删除的行");
	}
}

function addForm() {
	$("#df").dialog({title:"新建",modal:true,resizable:true});
	$('#ff').form('clear');
	cur_url = add_url;
	$("#df").dialog("open");
}

function saveAddForm() {
	$.post(cur_url, $("#ff").serialize()).done(function(json) {
		if (json.result) {
			closeForm();
			$('#dg').datagrid('reload');
		} else {
			alert(json.msg);
		}
	}, "json");
}

function closeForm() {
	$('#ff').form('clear');
	$("#df").dialog('close');
}